<template>
    <view class="credit-rules-page">
        <!-- 记录列表 -->
        <view class="record-list">
            <view class="record-item" v-for="(item, index) in records" :key="index">
                <view class="item-left">
                    <text class="record-type">{{ item.type }}</text>
                </view>
                <view class="item-right">
                    <text class="init-value" v-if="item.type === '注册成功'">初始诚信值：{{item.value.toFixed(1)}}</text>
                    <text class="record-value" v-else>{{ item.value > 0 ? "+" : "" }}{{ item.value }}</text>
                </view>
            </view>
        </view>
        <view class="credit-rules-tips">
            温馨提示：诚信值低于0分账号将做封禁处理
        </view>
    </view>
</template>

<script>
export default {
    data() {
        return {
            records: [],
        };
    },
    onLoad() {
        this.fetchHonestyRules();
    },
    methods: {
        async fetchHonestyRules() {
            try {
                const data = await this.$http.get('/h5/user/honestyRule')
                console.log('诚信值规则：', data.data); // data.data
                let total = 0;
                this.records = data.data && data.data.map(item => {
                    total += parseFloat(item.after);
                    return {
                        type: item.description,
                        value: item.value,
                    }
                });
            } catch (error) {}
        },
        // 导航到指定页面
        navigateTo(url) {
            uni.navigateTo({
                url: url,
            });
        },
    },
};
</script>

<style scoped>
.credit-rules-page {
    padding: 20rpx 26rpx;
}


.record-list {
    background-color: #fff;
    border-radius: 16rpx;
    padding: 0 40rpx;
}

.record-list .list-title {
    font-size: 28rpx;
    color: #333;
    padding: 30rpx 0;
    border-bottom: 1rpx solid #eee;
}

.record-list .record-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 36rpx 0;
    border-bottom: 1rpx solid #eee;
}

.record-list .record-item:last-child {
    border-bottom: none;
}

.record-list .item-left {
    display: flex;
    flex-direction: column;
}

.record-list .record-type {
    font-family: Source Han Sans CN, Source Han Sans CN;
    font-weight: 500;
    font-size: 32rpx;
    color: #0B1F20;
    line-height: 50rpx;
}



.record-list .record-value {
    font-family: Source Han Sans CN, Source Han Sans CN;
    font-weight: 400;
    font-size: 32rpx;
    color: #0B1F20;
    line-height: 50rpx;
    text-align: right;
}

.credit-rules-tips {
    font-family: Source Han Sans CN, Source Han Sans CN;
    font-weight: 400;
    font-size: 24rpx;
    color: #999999;
    line-height: 48rpx;
    text-align: center;
    padding-top: 32rpx;
}

.item-right .init-value {
    font-family: Source Han Sans CN, Source Han Sans CN;
    font-weight: 400;
    font-size: 32rpx;
    color: #FF7937;
    line-height: 50rpx;
    text-align: right;
}
</style>
